package com.logic.userdatas.accountNums;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.bean.UserCountBean;
import com.context.db.DBContext;

public class GetAccountNumbers {
	
	public List<UserCountBean> getAccountNumbersList( String adminID ){
		
		String totalCount = "0";
		String testCount = "0";
		String normalCount = "0";
		String tempCount = "0";
		
		List<UserCountBean> mList = new ArrayList<UserCountBean>();
		
		Connection conn = DBContext.getDBInstance( DBContext.MYSQL ).getDBConnection();
		
		CallableStatement cst = null;
		
		
		try {
			cst = conn.prepareCall( "{call db.admingetuserscount_proc(?,?,?,?,?)}" );
			
			cst.setString(1, adminID );
			
			cst.registerOutParameter( 2, java.sql.Types.VARCHAR );
			cst.registerOutParameter( 3, java.sql.Types.VARCHAR );
			cst.registerOutParameter( 4, java.sql.Types.VARCHAR );
			cst.registerOutParameter( 5, java.sql.Types.VARCHAR );
			
			cst.execute();
			
			totalCount = cst.getString( 2 );
			testCount = cst.getString( 3 );
			normalCount = cst.getString( 4 );
			tempCount = cst.getString( 5 );
			
			System.out.println( "totalCount:" + totalCount );
			System.out.println( "testCount:" + testCount );
			System.out.println( "normalCount:" + normalCount );
			System.out.println( "tempCount:" + tempCount );
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if( cst != null ){
				
				try {
					cst.close();
					
					cst = null;
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
		}
		
		UserCountBean bean = new UserCountBean();
		
		bean.setTotalCount( totalCount );
		bean.setNormalCount( normalCount );
		bean.setTestCount( testCount );
		bean.setTempCount(tempCount);
		
		mList.add( bean );
		
		return mList;
		
	} 

}

